package CA;


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;


public class Helper_test extends TestCase {
	
private static final double NaN = 0;
	//private final String MainExamineLocation = "C:/SignatureOutput/noscan/UnitTests/";
	private final String MainExaminLocation = System.getProperty("user.dir") + "/UnitTestData/";
	
	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	
	public void testisMissingModule()
	{
		Helper h = new Helper();
		assertFalse(h.isMissingModule("Fred"));
		assertTrue(h.isMissingModule("^*^Fred"));
		assertFalse(h.isMissingModule("F^*^red"));
	}
	
	
	public void testgetMissingModuleInfoByFile()
	{
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		assertEquals(0, h.getMissingModuleInfoByFile(f0));
		assertEquals(1, h.getMissingModuleInfoByFile(f1));
		assertEquals(2, h.getMissingModuleInfoByFile(f2));
		assertEquals(3, h.getMissingModuleInfoByFile(f3));
		assertEquals(4, h.getMissingModuleInfoByFile(f4));
		
	}
	
	
	public void testgetTotalLinesInAllFiles(){
		final String compareFile = MainExaminLocation+"missingStack/filecount/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		fileList=cs.getFileList(compareFile);
		cs.BuildFileData(fileList, compareFile, false);
	
		// This may be skewed by .svn files
		assertEquals(37,h.getTotalLinesInAllFiles(fileList, false)); //previously 17
	}
	
	public void testGetTotalNumberOfFoldersWithMissingCrashInfo()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder2/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		fileList=cs.getFileList(compareFile);
		cs.BuildFileData(fileList, compareFile, false);
		assertEquals(2,h.getTotalNumberOfFoldersWithMissingCrashInfo(fileList, false));
		
	}
	
	// Get the total number of folders being examined
	public void testGetTotalNumberOfFolders()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder2/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		fileList=cs.getFileList(compareFile);
		cs.BuildFileData(fileList, compareFile, false);
		assertEquals(3,h.getTotalNumberOfFolders(fileList, false));
	}
	
	// Get the total number of lines of missing crash information in all of the files
	public void testGetTotalLinesMissingCrashInfoInAllFiles()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder2/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		fileList=cs.getFileList(compareFile);
		cs.BuildFileData(fileList, compareFile, false);
		
		assertEquals(10,h.getTotalLinesMissingCrashInfoInAllFiles(fileList, false));
	}
	
	// Test to see if it is a file that should be examined
	public void testIsExamineFile(){
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		File completeReport=new File(compareFile+"CompleteReport.txt"); // 3 errors
		File compareReport=new File(compareFile+"CompareReport.txt"); // 4 errors
		assertTrue(h.isExamineFile(f0));
		assertTrue(h.isExamineFile(f1));
		assertTrue(h.isExamineFile(f2));
		assertTrue(h.isExamineFile(f3));
		assertTrue(h.isExamineFile(f4));
		assertFalse(h.isExamineFile(completeReport));
		assertFalse(h.isExamineFile(compareReport));
		
	}

	// Get the minimum number of lines between two files
	public void testGetMinLineCount(){
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		File completeReport=new File(compareFile+"CompleteReport.txt"); // 3 errors
		File compareReport=new File(compareFile+"CompareReport.txt"); // 4 errors
		assertSame(17,h.getMinLineCount(f0, f1));
		assertSame(21,h.getMinLineCount(f3, f1));
		assertSame(6,h.getMinLineCount(f2, completeReport));
		assertSame(6,h.getMinLineCount(completeReport, compareReport));
		assertSame(17,h.getMinLineCount(f0, f4));
		
	}
	
	// Get the Maximum number of lines between two files
	public void testGetMaxLineCount(){
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		File completeReport=new File(compareFile+"CompleteReport.txt"); // 3 errors
		File compareReport=new File(compareFile+"CompareReport.txt"); // 4 errors
		assertSame(21,h.getMaxLineCount(f0, f1));
		assertSame(23,h.getMaxLineCount(f3, f1));
		assertSame(22,h.getMaxLineCount(f2, completeReport));
		assertSame(10,h.getMaxLineCount(completeReport, compareReport));
		assertSame(24,h.getMaxLineCount(f0, f4));
		assertSame(24,h.getMaxLineCount(f4, f4));
		
	}
	
	public void testGetFileLineCount()
	{
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		File completeReport=new File(compareFile+"CompleteReport.txt"); // 3 errors
		File compareReport=new File(compareFile+"CompareReport.txt"); // 4 errors
		assertSame(17,h.getFileLineCount(f0));
		assertSame(21,h.getFileLineCount(f1));
		assertSame(22,h.getFileLineCount(f2));
		assertSame(23,h.getFileLineCount(f3));
		assertSame(24,h.getFileLineCount(f4));
		assertSame(6,h.getFileLineCount(completeReport));
		assertSame(10,h.getFileLineCount(compareReport));
		
	}
	
	public void testGetLineInformation()
	{
		String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		Helper h = new Helper();
		File f0=new File(compareFile+"0.txt"); // 0 errors
		File f1=new File(compareFile+"1.txt"); // 1 errors
		File f2=new File(compareFile+"2.txt"); // 2 errors
		File f3=new File(compareFile+"3.txt"); // 3 errors
		File f4=new File(compareFile+"4.txt"); // 4 errors
		File completeReport=new File(compareFile+"CompleteReport.txt"); // 3 errors
		File compareReport=new File(compareFile+"CompareReport.txt"); // 4 errors
		assertEquals("default",h.getLineInformation(f0, 17));
		assertEquals("xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631",h.getLineInformation(f1, 14));
		assertEquals("xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631",h.getLineInformation(f2, 15));
		assertEquals("kernel32.dll^*^BaseThreadStart^*^",h.getLineInformation(f3, 22));
		assertEquals("^*^@0x7fff^*^",h.getLineInformation(f4, 6));
	}
	
	// Get the folders in a directory
	public void testGetFolderList()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		assertSame(1,h.getFolderList(compareFile).size());
		
	}
	
	
	
	// Get the files in a directory
	public void testGetFileList()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder1/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		assertSame(7,h.getFileList(compareFile).size());
		
	}

		// test getting the complete contents of a file
	public void testGetCompleteFileContents()
	{
		String compareFile = MainExaminLocation+"/ScanTypes/TotalStringTests/";
		Helper h = new Helper();

		
		// test the basic implemnetation by reading from two files
		File f1=new File(compareFile+"file1.txt"); 
		File f2=new File(compareFile+"file2.txt");
		assertEquals(h.getCompleteFileContents(f1),"DanISTotallyCool");
		assertEquals(h.getCompleteFileContents(f2),"DanISTotallyCoolThisIsBeforeChristmasatidxx32.dll^*^atidxx32.dll@0x33756e^*^");


		// Test reading from actually created objects
		// This should probably be moved to a new location
		
		
	}

	
	
	// Test trim function 
	public void testRoundDouble()
	{
		Helper h = new Helper();
		assertEquals(h.roundDouble(123),123.0);
		assertEquals(h.roundDouble(1.0),1.0);
		assertEquals(h.roundDouble(1.1),1.1);
		assertEquals(h.roundDouble(1.11),1.11);
		assertEquals(h.roundDouble(1.111),1.11);
		assertEquals(h.roundDouble(-123),-123.0);
		assertEquals(h.roundDouble(-1.0),-1.0);
		assertEquals(h.roundDouble(-1.1),-1.1);
		assertEquals(h.roundDouble(-1.11),-1.11);
		assertEquals(h.roundDouble(-1.111),-1.11);
		assertEquals(h.roundDouble(NaN),0.0);
	}
	
	

	// test getArrayIndex
	public void testGetArrayIndex()
	{
		final String compareFile =  MainExaminLocation+"StringDifference/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();
		fileList=cs.getFileList(compareFile);
		cs.BuildFileData(fileList, compareFile, false);
	
		assertEquals("rr-16",fileList.get(h.getArrayIndex(fileList, "rr-16")).getCrashName());
		assertEquals("rr-29",fileList.get(h.getArrayIndex(fileList, "rr-29")).getCrashName());
		assertEquals("rr-55",fileList.get(h.getArrayIndex(fileList, "rr-55")).getCrashName());
		assertEquals("lcs",fileList.get(h.getArrayIndex(fileList, "lcs")).getCrashName());
		assertEquals("NW",fileList.get(h.getArrayIndex(fileList, "NW")).getCrashName());
		
	}	
	
	
	// GET WORKING WITH .SVN FILES
	// Write test to check isExamineFolder
	public void testGetMissingStackInfoFiles()
	{
		final String compareFile = MainExaminLocation+"missingStack/missingStackFolder4/";
		CrashSuper cs = new CrashSuper();
		Helper h = new Helper();
		List<FileInfo> fileList = new ArrayList<FileInfo>();	
		fileList=cs.getFileList(compareFile);
		
		// get the number of items to be removed
		assertEquals(h.getMissingStackInfoFiles(fileList, compareFile, false),6);
			
	}
	
	// 
	public void testIsScanFileByStringName(){
		Helper h = new Helper();
		assertTrue(h.isScanFileByStringName("fred.txt"));
		assertFalse(h.isScanFileByStringName("CompareReport.txt"));
		assertFalse(h.isScanFileByStringName("URL"));
		assertFalse(h.isScanFileByStringName("SVN"));
	}

	public void testGetFileNameFromAbsolutePath(){
		Helper h = new Helper();
		final String AbsolutePath1="C:/Users/Dan/workspace/CrashSignature/UnitTestData/missingStack/missingStackFolder5/folder2/0.txt";
		final String AbsolutePath2="C:/missingStackFolder5/folder2/Smith.txt";
		final String AbsolutePath3="C:/Dan.txt";
		final String AbsolutePath4="C:/UnitTestData/missingStack/missingStackFolder5/folder2/000.txt";
		
		assertEquals(h.getFileNameFromAbsolutePath(AbsolutePath1),"0.txt");
		assertEquals(h.getFileNameFromAbsolutePath(AbsolutePath2),"Smith.txt");
		assertEquals(h.getFileNameFromAbsolutePath(AbsolutePath3),"Dan.txt");
		assertEquals(h.getFileNameFromAbsolutePath(AbsolutePath4),"000.txt");
		
	}

	// Set the information of a single line of a file
	public void testsetLineInformation() throws IOException{
		Helper h = new Helper();
		final String CrashSuperLocation = MainExaminLocation+"missingStack/missingStackFolder5/folder2/";
		File f0=new File(CrashSuperLocation+"0.txt"); // 0 errors
		
		// make sure the file distance is correct 
		assertEquals(17,h.getFileLineCount(f0));
		
		// Check the value by default
		assertEquals(h.getLineInformation(f0,4),"xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631"); // make sure that the file is setup properly by default
	
		// make sure the value is changed properly
		h.setLineInformation(f0, "fred",4);
		assertEquals(h.getLineInformation(f0,4),"fred"); // make sure that the file is setup properly by default
	
		// Change the file back
		h.setLineInformation(f0, "xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631",4);
		assertEquals(h.getLineInformation(f0,4),"xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631"); // make sure that the file is setup properly by default	
		
		// Make sure the file distance has not changed
		assertEquals(17,h.getFileLineCount(f0));
		
	}

	
	// getFileNameFromAbsolutePath
	
//	getFilePathFromAbsolultePath

	
	
	public void testGetFilePathFromAbsolultePath(){
		Helper h = new Helper();
		final String AbsolutePath1="C:/Users/Dan/workspace/CrashSignature/UnitTestData/missingStack/missingStackFolder5/folder2/0.txt";
		final String AbsolutePath2="C:/missingStackFolder5/folder2/Smith.txt";
		final String AbsolutePath3="C:/Dan.txt";
		final String AbsolutePath4="C:/UnitTestData/missingStack/missingStackFolder5/folder2/000.txt";
		
		// commented out because it is hard to match the // character information.
	//	assertEquals(h.getFilePathFromAbsolultePath(AbsolutePath1),"C:\\Users\\Dan\\workspace\\CrashSignature\\UnitTestData\\missingStack\\missingStackFolder5\\folder2\\");
	//	assertEquals(h.getFilePathFromAbsolultePath(AbsolutePath2),"C:/missingStackFolder5/folder2/");
		assertEquals(h.getFilePathFromAbsolultePath(AbsolutePath3),"C:\\/");
	//	assertEquals(h.getFilePathFromAbsolultePath(AbsolutePath4),"C:/UnitTestData/missingStack/missingStackFolder5/folder2/");
	
	}
	

	public void testGetCompleteFileContentsWithLineBreak()
	{
		final String Location = MainExaminLocation+"missingStack/missingStackFolder6/folder2/";
		Helper h = new Helper();

		
		// test the basic implemnetation by reading from two files
		File f0=new File(Location+"0.txt"); 
		File f1=new File(Location+"1.txt");
		File f4=new File(Location+"4.txt");
		
		assertEquals("xul.dll^*^nsHttpTransaction::WriteSegments^*^netwerk/protocol/http/nsHttpTransaction.cpp:563@!@xul.dll^*^txCoreFunctionCall::`vector deleting destructor'^*^@!@xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631@!@xul.dll^*^nsHttpConnection::OnInputStreamReady^*^netwerk/protocol/http/nsHttpConnection.cpp:917@!@",h.getCompleteFileContentsWithLineBreak(f0));
		assertEquals("xul.dll^*^nsSocketInputStream::Read^*^netwerk/base/src/nsSocketTransport2.cpp:352@!@xul.dll^*^nsHttpConnection::OnWriteSegment^*^netwerk/protocol/http/nsHttpConnection.cpp:768@!@xul.dll^*^nsHttpTransaction::WritePipeSegment^*^netwerk/protocol/http/nsHttpTransaction.cpp:533@!@^*^@0x7fff^*^@!@xul.dll^*^nsHttpTransaction::WriteSegments^*^netwerk/protocol/http/nsHttpTransaction.cpp:563@!@xul.dll^*^txCoreFunctionCall::`vector deleting destructor'^*^@!@xul.dll^*^nsHttpConnection::OnSocketReadable^*^netwerk/protocol/http/nsHttpConnection.cpp:800@!@",h.getCompleteFileContentsWithLineBreak(f1));
		assertEquals("xul.dll^*^nsHttpTransaction::WriteSegments^*^netwerk/protocol/http/nsHttpTransaction.cpp:563@!@xul.dll^*^txCoreFunctionCall::`vector deleting destructor'^*^@!@xul.dll^*^nsThread::ProcessNextEvent^*^xpcom/threads/nsThread.cpp:631@!@xul.dll^*^nsHttpConnection::OnInputStreamReady^*^netwerk/protocol/http/nsHttpConnection.cpp:917@!@",h.getCompleteFileContentsWithLineBreak(f0));
		
	}


	// Combine both for just keeping the tests simpler
	public void testGetLongestAndShortestArrayLength()
	{
		Helper h = new Helper();
		ArrayList<String> file1list = new ArrayList<String>(1);
		ArrayList<String> file2list = new ArrayList<String>(2);
		ArrayList<String> file3list = new ArrayList<String>(3);
		ArrayList<String> file4list = new ArrayList<String>(4);
	
		file1list.add("x");
		
		file2list.add("x");
		file2list.add("x");
		
		file3list.add("x");
		file3list.add("x");
		file3list.add("x");
		
		file4list.add("x");
		file4list.add("x");
		file4list.add("x");
		file4list.add("x");
		
		// just double check the sizes
		assertEquals(1, file1list.size());
		assertEquals(2, file2list.size());
		assertEquals(3, file3list.size());
		assertEquals(4, file4list.size());
		
		
		assertEquals(1,h.getLongestArrayLength(file1list, file1list));
		assertEquals(2,h.getLongestArrayLength(file1list, file2list));
		assertEquals(3,h.getLongestArrayLength(file1list, file3list));
		assertEquals(4,h.getLongestArrayLength(file1list, file4list));
		assertEquals(2,h.getLongestArrayLength(file2list, file2list));
		assertEquals(3,h.getLongestArrayLength(file2list, file3list));
		assertEquals(4,h.getLongestArrayLength(file2list, file4list));
		assertEquals(3,h.getLongestArrayLength(file3list, file3list));
		assertEquals(4,h.getLongestArrayLength(file3list, file4list));
		assertEquals(4,h.getLongestArrayLength(file4list, file4list));
		assertEquals(3,h.getLongestArrayLength(file3list, file1list)); // just reverse some of the inputs
		
		
		assertEquals(1,h.getShortestArrayLength(file1list, file1list));
		assertEquals(1,h.getShortestArrayLength(file1list, file2list));
		assertEquals(1,h.getShortestArrayLength(file1list, file3list));
		assertEquals(1,h.getShortestArrayLength(file1list, file4list));
		assertEquals(2,h.getShortestArrayLength(file2list, file2list));
		assertEquals(2,h.getShortestArrayLength(file2list, file3list));
		assertEquals(2,h.getShortestArrayLength(file2list, file4list));
		assertEquals(3,h.getShortestArrayLength(file3list, file3list));
		assertEquals(3,h.getShortestArrayLength(file3list, file4list));
		assertEquals(4,h.getShortestArrayLength(file4list, file4list));
		assertEquals(1,h.getShortestArrayLength(file3list, file1list)); // just reverse some of the inputs
		
		
	}
	
	// combine to save testing items
	public void testGetLongestAndShortestArray()
	{
		
		Helper h = new Helper();
		ArrayList<String> file1list = new ArrayList<String>(1);
		ArrayList<String> file2list = new ArrayList<String>(2);
		ArrayList<String> file3list = new ArrayList<String>(3);
		ArrayList<String> file4list = new ArrayList<String>(4);
		ArrayList<String> file4blist = new ArrayList<String>(4); // create a list with a duplicate length of 4
	
		file1list.add("x");
		
		file2list.add("x");
		file2list.add("x");
		
		file3list.add("x");
		file3list.add("x");
		file3list.add("x");
		
		file4list.add("x");
		file4list.add("x");
		file4list.add("x");
		file4list.add("x");
		
		file4blist.add("b1");
		file4blist.add("b2");
		file4blist.add("b3");
		file4blist.add("b4");
		
		// just double check the sizes
		assertEquals(1, file1list.size());
		assertEquals(2, file2list.size());
		assertEquals(3, file3list.size());
		assertEquals(4, file4list.size());
		
		
		assertEquals(1,h.getLongestArray(file1list, file1list).size());
	
		assertEquals(2,h.getLongestArray(file1list, file2list).size());
		assertEquals(3,h.getLongestArray(file1list, file3list).size());
		assertEquals(4,h.getLongestArray(file1list, file4list).size());
		assertEquals(2,h.getLongestArray(file2list, file2list).size());
		assertEquals(3,h.getLongestArray(file2list, file3list).size());
		assertEquals(4,h.getLongestArray(file2list, file4list).size());
		assertEquals(3,h.getLongestArray(file3list, file3list).size());
		assertEquals(4,h.getLongestArray(file3list, file4list).size());
		assertEquals(4,h.getLongestArray(file4list, file4list).size());
		assertEquals(3,h.getLongestArray(file3list, file1list).size()); // just reverse some of the inputs
		
		
		assertEquals(1,h.getShortestArray(file1list, file1list).size());
		assertEquals(1,h.getShortestArray(file1list, file2list).size());
		assertEquals(1,h.getShortestArray(file1list, file3list).size());
		assertEquals(1,h.getShortestArray(file1list, file4list).size());
		assertEquals(2,h.getShortestArray(file2list, file2list).size());
		assertEquals(2,h.getShortestArray(file2list, file3list).size());
		assertEquals(2,h.getShortestArray(file2list, file4list).size());
		assertEquals(3,h.getShortestArray(file3list, file3list).size());
		assertEquals(3,h.getShortestArray(file3list, file4list).size());
		assertEquals(4,h.getShortestArray(file4list, file4list).size());
		assertEquals(1,h.getShortestArray(file3list, file1list).size()); // just reverse some of the inputs

				
		
		// now test two arrays of the same length to make sure that different ones are returned for longest and shortest
		assertEquals(4,h.getShortestArray(file4blist, file4blist).size());
		assertEquals("b1",h.getShortestArray(file4list, file4blist).get(0));
		assertEquals("x",h.getLongestArray(file4list, file4blist).get(0));
		assertEquals("x",h.getLongestArray(file4list, file4blist).get(1));
		
		
	}
	
	
	public void testGetCompleteArrayContents()
	{
	
		//CHANGE THIS
		Helper h = new Helper();
		ArrayList<String> file1list = new ArrayList<String>(5);
		ArrayList<String> tempList1 = new ArrayList<String>(3);
		file1list.add("f1");
		file1list.add("f2");
		file1list.add("f3");
		file1list.add("f4");
		file1list.add("f5");
		
		tempList1.add("xx");
		tempList1.add("f2");
		tempList1.add("f3");
		tempList1.add("f4");
		
		assertEquals("f1&*&f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		assertEquals("xx&*&f2&*&f3&*&f4&*&",h.getCompleteArrayContents(tempList1));
		
	}
	
	
	public void testGetAddRemoveItemsStartArray()
	{
		Helper h = new Helper();
		ArrayList<String> file1list = new ArrayList<String>(5);
		ArrayList<String> file2list = new ArrayList<String>(3);
		ArrayList<String> templist = new ArrayList<String>();
		ArrayList<String> emptylist = new ArrayList<String>();
		
		file1list.add("f1");
		file1list.add("f2");
		file1list.add("f3");
		file1list.add("f4");
		file1list.add("f5");
		
		// check to make sure that everything was built ok
		assertEquals(5, file1list.size());
		
		
		// try passing in a blank file
		assertEquals(0, h.getRemoveItemsEndArray(emptylist,0).size());
		assertEquals("f1&*&f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		
		
		assertEquals(5, h.getRemoveItemsEndArray(file1list,0).size());
		assertEquals("f1&*&f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		
		assertEquals(4, h.getRemoveItemsEndArray(file1list,1).size());
		assertEquals("f1&*&f2&*&f3&*&f4&*&",h.getCompleteArrayContents(file1list));
		file1list.add("f5");
		
		assertEquals(3, h.getRemoveItemsEndArray(file1list,2).size());
		assertEquals("f1&*&f2&*&f3&*&",h.getCompleteArrayContents(file1list));
		file1list.add("f4");
		file1list.add("f5");
		
		
		assertEquals(2, h.getRemoveItemsEndArray(file1list,3).size());
		assertEquals("f1&*&f2&*&",h.getCompleteArrayContents(file1list));
		file1list.add("f3");
		file1list.add("f4");
		file1list.add("f5");
		
		
		assertEquals(1, h.getRemoveItemsEndArray(file1list,4).size());
		assertEquals("f1&*&",h.getCompleteArrayContents(file1list));
		file1list.add("f2");
		file1list.add("f3");
		file1list.add("f4");
		file1list.add("f5");
		
		assertEquals(0, h.getRemoveItemsEndArray(file1list,5).size());
		assertEquals("",h.getCompleteArrayContents(file1list));
		file1list.add("f1");
		file1list.add("f2");
		file1list.add("f3");
		file1list.add("f4");
		file1list.add("f5");
		
		// test of removing items from the start of an array
		
		
		// make sure the file size is ok
		assertEquals(5, file1list.size());
		
		assertEquals(0, h.getRemoveItemsStartArray(emptylist,0).size());
		assertEquals("f1&*&f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		
		
		assertEquals(5, h.getRemoveItemsStartArray(file1list,0).size());
		assertEquals("f1&*&f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		
		assertEquals(4, h.getRemoveItemsStartArray(file1list,1).size());
		assertEquals("f2&*&f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		file1list.add(0, "f1");
		assertEquals(5, file1list.size());
		
		assertEquals(3, h.getRemoveItemsStartArray(file1list,2).size());
		assertEquals("f3&*&f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		file1list.add(0, "f1");
		file1list.add(0, "f2");
		assertEquals(5, file1list.size());
		
		assertEquals(2, h.getRemoveItemsStartArray(file1list,3).size());
		assertEquals("f4&*&f5&*&",h.getCompleteArrayContents(file1list));
		file1list.add(0, "f1");
		file1list.add(0, "f2");
		file1list.add(0, "f3");
		assertEquals(5, file1list.size());
		
		assertEquals(1, h.getRemoveItemsStartArray(file1list,4).size());
		assertEquals("f5&*&",h.getCompleteArrayContents(file1list));
		file1list.add(0, "f1");
		file1list.add(0, "f2");
		file1list.add(0, "f3");
		file1list.add(0, "f4");
		assertEquals(5, file1list.size());
		
		assertEquals(0, h.getRemoveItemsStartArray(file1list,5).size());
		assertEquals("",h.getCompleteArrayContents(file1list));
		
	}
	
	
	// test combing building a string from an array and removing items from start and end of an array
	
	/*
	public void testGetLineItem(){
		Helper h = new Helper();
		final String line1="xul.dll^*^nsHttpConnection::OnWriteSegment^*^netwerk/protocol/http/nsHttpConnection.cpp:768";
		final String line2="^*^nsHttpConnection::OnWriteSegment^*^netwerk/protocol/http/nsHttpConnection.cpp:768";
		final String line3="^*^^*^";
		final String line4="xul.dll^*^nsHttpConnection::OnWriteSegment^*^";
	
		assertEquals("xul.dll",h.getLineItem(line1, 0));
		assertEquals("nsHttpConnection::OnWriteSegment",h.getLineItem(line1, 1));
		assertEquals("netwerk/protocol/http/nsHttpConnection.cpp:768",h.getLineItem(line1, 2));
	
		assertEquals("",h.getLineItem(line2, 0));
		assertEquals("nsHttpConnection::OnWriteSegment",h.getLineItem(line2, 1));
		assertEquals("netwerk/protocol/http/nsHttpConnection.cpp:768",h.getLineItem(line2, 2));

		assertEquals(" ",h.getLineItem(line3, 0));
	//	assertEquals("",h.getLineItem(line3, 1));
	//	assertEquals("",h.getLineItem(line3, 2));
		
		
	}
		*/
	
	
	/*
	 * FIX THIS
	 * 
	// Make sure the correct number of files are being built
	public void testGetAllFileNames(){
		final String CrashSuperLocation = MainExaminLocation+"missingStack/missingStackFolder5/";
		Helper h = new Helper();
		List<String> AllFiles=new ArrayList<String>();	
		AllFiles=h.getAllFileNames(CrashSuperLocation);
		
		assertEquals(AllFiles.size(),22); // Make sure that files that should be ignored are.
	}
	*/
	
	
	public void testGetURLFromFile()
	{
		Helper h = new Helper();
		final String compareFile1 =System.getProperty("user.dir") + "/UnitTestData/GetFileName/CrashReportsinSocketSend/";
		final String compareFile2 =System.getProperty("user.dir") + "/UnitTestData/GetFileName/CrashReportsinSocketWrite/";
		
		assertEquals("URL not found",h.getURLFromFolder(compareFile1));
		assertEquals("https://crash-stats.mozilla.com/report/list?range_value=7&range_unit=days&date=2011-11-30&signature=SocketWrite&version=Firefox%3A9.0b1",h.getURLFromFolder(compareFile2));
		
	}
	
	
	
	// 
	public void testIsFirstValBreak()
	{
		Helper h = new Helper();
		final String val1= "1@!@l2@!@l3@!@l4@!@";
		final String val2= "@!@l2@!@l3@!@l4@!@";
		assertFalse(h.isFirstValBreak(val1));
		assertTrue(h.isFirstValBreak(val2));
	}
	
	
	public void testIsRowInFile(){
		Helper h = new Helper();
		String compareFile = MainExaminLocation+"/BrodieTest/folder1/";
		File af1=new File(compareFile+"af1.txt"); 
		File af2=new File(compareFile+"af2.txt"); 

		assertTrue(h.isRowInFile("L1", af1));
		assertFalse(h.isRowInFile("L11", af1));
		assertFalse(h.isRowInFile("L1", af2));
		

	
	}
	
	
	
}
